<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    x:Class="OpenLS.Chart.UI.LineChartResources"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:chart="http://schemas.Kherty.com/office/2007/chart"
  xmlns:chartui="clr-namespace:OpenLS.Chart.UI"
  xmlns:Internals="clr-namespace:OpenLS.Chart.UI.Internals"  
>
  <ResourceDictionary.MergedDictionaries>
    <chartui:Axis2DResources/>
  </ResourceDictionary.MergedDictionaries>

  <DataTemplate DataType="{x:Type chart:LineChart}">
    <Grid
          chartui:ChartElement.Chart="{Binding}"
        chartui:ChartElement.XAxisInfo="{Binding RelativeSource ={RelativeSource Self}, Path=(chartui:ChartElement.Observer).MaxIndex, Converter={x:Static Internals:ChartConverters.SimpleAxisInfoFactory}}"
        >
      <chartui:ChartElement.Observer>
        <MultiBinding Converter="{x:Static Internals:ChartConverters.SeriesObserverFactory}">
          <Binding Path="Series"/>
          <Binding Path="Grouping"/>
        </MultiBinding>
      </chartui:ChartElement.Observer>
            <chartui:ChartElement.YAxisInfo>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.AxisInfoFactory}">
                    <Binding Path="ValueAxis.Minimum"/>
                    <Binding Path="ValueAxis.Maximum"/>
                    <Binding Path="(chartui:ChartElement.Observer).ActualMinimum" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="(chartui:ChartElement.Observer).Maximum" RelativeSource="{RelativeSource Self}"/>
                </MultiBinding>

            </chartui:ChartElement.YAxisInfo>
                <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height ="Auto"/>
      </Grid.RowDefinitions>
            <ContentPresenter Content="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.PlotArea)}"
                          ContentTemplate="{x:Static chartui:PlotAreaResources.PlotAreaBackgroundTemplate}"
                          Grid.Row="1" Grid.Column="1"/>

            <ContentPresenter Name="seriesAxis"
  Grid.Row="1" Grid.Column="0" Content="{Binding ValueAxis}" 
  chartui:AxisElement.Orientation="Vertical"
  chartui:AxisElement.Minimum="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
  chartui:AxisElement.Maximum="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Maximum}">
            </ContentPresenter>
            <Grid Grid.Row="2" Grid.Column="1" Name="categoryAxisHolder" chartui:AxisElement.ItemsSource="{Binding Categories.Values}">
                <ContentPresenter Name="categoryAxis"
                              Content="{Binding HorizontalAxis}"
                              chartui:AxisElement.Orientation="Horizontal"
                              chartui:AxisElement.Maximum="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Maximum}"
                              />

            </Grid>
            <Grid Grid.Row="1" Grid.Column="1" 
                chartui:AxisElement.Minimum="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"
                chartui:AxisElement.Maximum="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Maximum}"
                  chartui:AxisElement.Orientation="Vertical">
                <ContentPresenter  Name="minorGrid">
                    <chartui:AxisElement.MinorStep>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMinorStepConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                        </MultiBinding>
                    </chartui:AxisElement.MinorStep>
                    <ContentPresenter.Content>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMinorInfoConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.MinorStep)"/>
                            <Binding Path="ValueAxis"/>
                            <Binding Path="ValueAxis.MinorGridLines"/>
                        </MultiBinding>
                    </ContentPresenter.Content>

                </ContentPresenter>
                <ContentPresenter Name="majorGrid">
                    <chartui:AxisElement.MajorStep>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMajorStepConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                        </MultiBinding>
                    </chartui:AxisElement.MajorStep>
                    <ContentPresenter.Content>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMajorInfoConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.MajorStep)"/>
                            <Binding Path="ValueAxis"/>
                            <Binding Path="ValueAxis.MajorGridLines"/>
                        </MultiBinding>
                    </ContentPresenter.Content>
                </ContentPresenter>
            </Grid>
            <ItemsControl Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Path=Series}" ToolTip="{x:Static Internals:UIStringTable.PlotArea}">
        <ItemsControl.ItemsPanel>
          <ItemsPanelTemplate>
            <Grid/>
          </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
      </ItemsControl>
    </Grid>
  </DataTemplate>

</ResourceDictionary>